﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Dan.Common
{
    /// <summary>
    /// 获取GUID数据
    /// </summary>
    public class GUIDHelper
    {
        /// <summary> 
        /// 根据GUID获取16位的唯一字符串 
        /// </summary>  
        /// <returns></returns> 
        public static string GenerateStringID()
        {
            long i = 1;
            foreach (byte b in Guid.NewGuid().ToByteArray())
            {
                i *= ((int)b + 1);
            }
            return string.Format("{0:x}", i - DateTime.Now.Ticks);
        }
        /// <summary> 
        /// 根据GUID获取19位的唯一数字序列 
        /// </summary> 
        /// <returns></returns> 
        public static long GuidToLongID()
        {
            byte[] buffer = Guid.NewGuid().ToByteArray();
            return BitConverter.ToInt64(buffer, 0);
        }



    }
}
